<!DOCTYPE html>

<html>
<head>
  <title>Observable</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
      <ul id="jump_to">
        <li>
          <a class="large" href="javascript:void(0);">Jump To &hellip;</a>
          <a class="small" href="javascript:void(0);">+</a>
          <div id="jump_wrapper">
          <div id="jump_page">
            
              
              <a class="source" href="Observable.coffee.html">
                Observable.coffee.md
              </a>
            
              
              <a class="source" href="header.coffee.html">
                header.coffee.md
              </a>
            
          </div>
        </li>
      </ul>
    
    <ul class="sections">
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              <h1 id="observable">Observable</h1>

            </div>
            
            <div class="content"><div class='highlight'><pre>	
	<span class="hljs-built_in">window</span>.Observable = Observable = Function.overload [
	
		Function.From<span class="hljs-function"><span class="hljs-params">(Value)</span> <span class="hljs-params">(constructor)</span> -&gt;</span> <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> Error <span class="hljs-string">"Cannot make observable from <span class="hljs-subst">#{constructor}</span>"</span> 
	
	]</pre></div></div>
            
        </li>
        
        
        <li id="section-2">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-2">&#182;</a>
              </div>
              <h2 id="observable-set">Observable Set</h2>

            </div>
            
            <div class="content"><div class='highlight'><pre>	
	<span class="hljs-built_in">window</span>.Observable = <span class="hljs-built_in">window</span>.Observable.extend [
	
		Function.From<span class="hljs-function"><span class="hljs-params">(Constructor.Inheriting Set)</span> <span class="hljs-params">(constructor)</span> -&gt;</span>
		
			<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">constructor</span></span>
		
				<span class="hljs-attribute">constructor</span>: <span class="hljs-function"><span class="hljs-params">(args...)</span> -&gt;</span>
					<span class="hljs-property">@events</span> = <span class="hljs-keyword">new</span> EventRegistry [<span class="hljs-string">'add'</span>,<span class="hljs-string">'remove'</span>,<span class="hljs-string">'change'</span>]
					<span class="hljs-property">@event</span> = Function.delegate<span class="hljs-function"> -&gt;</span> [<span class="hljs-property">@events</span>,<span class="hljs-property">@events</span>.get]
					<span class="hljs-keyword">super</span>
				
				<span class="hljs-attribute">add</span>:<span class="hljs-function"> -&gt;</span>
					length = <span class="hljs-property">@length</span>
					<span class="hljs-keyword">super</span>
					<span class="hljs-property">@event</span>(<span class="hljs-string">'add'</span>).raise @[length] <span class="hljs-keyword">if</span> length != <span class="hljs-property">@length</span>
					<span class="hljs-keyword">return</span> <span class="hljs-keyword">this</span>
				
				<span class="hljs-attribute">remove</span>: <span class="hljs-attribute">this</span>::remove.post <span class="hljs-function"><span class="hljs-params">(removed)</span> -&gt;</span>
					<span class="hljs-property">@event</span>(<span class="hljs-string">'remove'</span>).raise(item) <span class="hljs-keyword">for</span> item <span class="hljs-keyword">in</span> removed <span class="hljs-keyword">by</span> -<span class="hljs-number">1</span>
	
	]</pre></div></div>
            
        </li>
        
        
        <li id="section-3">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-3">&#182;</a>
              </div>
              <h2 id="observable-list">Observable List</h2>

            </div>
            
            <div class="content"><div class='highlight'><pre>	
	<span class="hljs-built_in">window</span>.Observable = <span class="hljs-built_in">window</span>.Observable.extend [
	
		Function.From<span class="hljs-function"><span class="hljs-params">(Constructor.Inheriting List)</span> <span class="hljs-params">(constructor)</span> -&gt;</span>
		
			<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">constructor</span></span>
		
				<span class="hljs-attribute">constructor</span>: <span class="hljs-function"><span class="hljs-params">(args...)</span> -&gt;</span>
					<span class="hljs-property">@events</span> = <span class="hljs-keyword">new</span> EventRegistry [<span class="hljs-string">'add'</span>,<span class="hljs-string">'change'</span>]
					<span class="hljs-property">@event</span> = Function.delegate<span class="hljs-function"> -&gt;</span> [<span class="hljs-property">@events</span>,<span class="hljs-property">@events</span>.get]
					<span class="hljs-keyword">super</span>
				
				<span class="hljs-attribute">add</span>: <span class="hljs-attribute">this</span>::add.post <span class="hljs-function"><span class="hljs-params">(list,item)</span> -&gt;</span>
					<span class="hljs-property">@event</span>(<span class="hljs-string">'add'</span>).raise(item)
	
	]</pre></div></div>
            
        </li>
        
        
        <li id="section-4">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-4">&#182;</a>
              </div>
              <h2 id="observable-map">Observable Map</h2>

            </div>
            
            <div class="content"><div class='highlight'><pre>	
	<span class="hljs-built_in">window</span>.Observable = <span class="hljs-built_in">window</span>.Observable.extend [
	
		Function.From<span class="hljs-function"><span class="hljs-params">(Constructor.Inheriting Map)</span> <span class="hljs-params">(constructor)</span> -&gt;</span>
		
			<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">constructor</span></span>
		
				<span class="hljs-attribute">constructor</span>: <span class="hljs-function"><span class="hljs-params">(args...)</span> -&gt;</span>
					<span class="hljs-property">@events</span> = <span class="hljs-keyword">new</span> EventRegistry [<span class="hljs-string">'add'</span>,<span class="hljs-string">'remove'</span>,<span class="hljs-string">'change'</span>]
					<span class="hljs-property">@event</span> = Function.delegate<span class="hljs-function"> -&gt;</span> [<span class="hljs-property">@events</span>,<span class="hljs-property">@events</span>.get]
					<span class="hljs-keyword">super</span>
				
				<span class="hljs-attribute">add</span>: <span class="hljs-attribute">this</span>::add.extend [			
					Function.From<span class="hljs-function"><span class="hljs-params">(Scalar,Value)</span> <span class="hljs-title">Function</span>.<span class="hljs-title">Chaining</span> <span class="hljs-params">(key,value)</span> -&gt;</span>
						value = <span class="hljs-property">@ensure</span> value
						<span class="hljs-property">@_</span>[key] = value
						<span class="hljs-property">@event</span>(<span class="hljs-string">'add'</span>).raise(key,value)
				]
			
				<span class="hljs-attribute">remove</span>: Function.Chaining <span class="hljs-function"><span class="hljs-params">(key)</span> -&gt;</span>
					<span class="hljs-keyword">if</span> <span class="hljs-property">@_</span>[key]?
						<span class="hljs-keyword">delete</span> <span class="hljs-property">@_</span>[key]
						<span class="hljs-property">@event</span>(<span class="hljs-string">'remove'</span>).raise(key)
	
	]</pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>
